home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / OpenTransport / Interfaces / PInterfaces / OpenTptSerial.p < prev    next >
Encoding:
Text File  |  1996-11-21  |  6.9 KB  |  194 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OpenTptSerial.p
  3.  
  4.      Contains:    Definitions for Serial Port
  5.  
  6.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9. }
  10. {$IFC UNDEFINED UsingIncludes}
  11. {$SETC UsingIncludes := 0}
  12. {$ENDC}
  13.  
  14. {$IFC NOT UsingIncludes}
  15.  UNIT OpenTptSerial;
  16.  INTERFACE
  17. {$ENDC}
  18.  
  19. {$IFC UNDEFINED __OPENTPTSERIAL__}
  20. {$SETC __OPENTPTSERIAL__ := 1}
  21.  
  22. {$I+}
  23. {$SETC OpenTptSerialIncludes := UsingIncludes}
  24. {$SETC UsingIncludes := 1}
  25.  
  26. {$IFC UNDEFINED __OPENTRANSPORT__}
  27. {$I OpenTransport.p}
  28. {$ENDC}
  29.  
  30. {$PUSH}
  31. {$ALIGN MAC68K}
  32. {$LibExport+}
  33.  
  34. {
  35. ******************************************************************************
  36. ** Module Definitions
  37. *******************************************************************************
  38. }
  39. {  XTI Level }
  40.  
  41. CONST
  42.     COM_SERIAL                    = 'SERL';
  43.  
  44. {  Version Number }
  45.     kSerialABVersion    =    '1.1.1';
  46. {  Module Names }
  47.     kSerialABName    =    'serialAB';
  48.     kSerialName        =    'serial';
  49.     kSerialPortAName    =    'serialA';
  50.     kSerialPortBName    =    'serialB';
  51.     kSerialABModuleID            = 7200;
  52.  
  53.     kOTSerialFramingAsync        = $01;                            {  Support Async serial mode              }
  54.     kOTSerialFramingHDLC        = $02;                            {  Support HDLC synchronous serial mode     }
  55.     kOTSerialFramingSDLC        = $04;                            {  Support SDLC synchronous serial mode     }
  56.     kOTSerialFramingAsyncPackets = $08;                            {  Support Async "packet" serial mode     }
  57.  
  58. {
  59. ******************************************************************************
  60. ** IOCTL Calls for Serial Drivers
  61. *******************************************************************************
  62. }
  63.     I_SetSerialDTR                = $5400;                        {  Set DTR (0 = off, 1 = on)         }
  64.     kOTSerialSetDTROff            = 0;
  65.     kOTSerialSetDTROn            = 1;
  66.     I_SetSerialBreak            = $5401;                        {  Send a break on the line - kOTSerialSetBreakOff = off,      }
  67.     kOTSerialSetBreakOn            = $FFFFFFFF;                    {  kOTSerialSetBreakOn = on, Any other number is the number  }
  68.     kOTSerialSetBreakOff        = 0;                            {  of milliseconds to leave break on, then auto shutoff         }
  69.     I_SetSerialXOffState        = $5402;                        {  Force XOFF state                  }
  70.     kOTSerialForceXOffTrue        = 1;                            {  1 = unconditionally set it         }
  71.     kOTSerialForceXOffFalse        = 0;                            {  0 = unconditionall clearr it         }
  72.     I_SetSerialXOn                = $5403;                        {  Send an XON character             }
  73.     kOTSerialSendXOnAlways        = 1;                            {  1 = send always                     }
  74.     kOTSerialSendXOnIfXOffTrue    = 0;                            {  0 = send only if in XOFF state     }
  75.     I_SetSerialXOff                = $5404;                        {  Send an XOFF character             }
  76.     kOTSerialSendXOffAlways        = 1;                            {  1 = send always                     }
  77.     kOTSerialSendXOffIfXOnTrue    = 0;                            {  0 = send only if in XON state     }
  78.  
  79. {
  80. ******************************************************************************
  81. ** Option Management for Serial Drivers
  82. *******************************************************************************
  83. }
  84. {
  85. ** These options are all 4-byte values.
  86. ** BaudRate is the baud rate.
  87. ** DataBits is the number of data bits.
  88. ** StopBits is the number of stop bits times 10.
  89. ** Parity is an enum
  90. }
  91.     SERIAL_OPT_BAUDRATE            = $0100;                        {  UInt32     }
  92.     SERIAL_OPT_DATABITS            = $0101;                        {  UInt32     }
  93.     SERIAL_OPT_STOPBITS            = $0102;                        {  UInt32 10, 15 or 20 for 1, 1.5 or 2     }
  94.     SERIAL_OPT_PARITY            = $0103;                        {  UInt32     }
  95.  
  96.     kOTSerialNoParity            = 0;
  97.     kOTSerialOddParity            = 1;
  98.     kOTSerialEvenParity            = 2;
  99.  
  100. {
  101.  The "Status" option is a 4-byte value option that is ReadOnly
  102.  It returns a bitmap of the current serial status
  103. }
  104.     SERIAL_OPT_STATUS            = $0104;
  105.     kOTSerialSwOverRunErr        = $01;
  106.     kOTSerialBreakOn            = $08;
  107.     kOTSerialParityErr            = $10;
  108.     kOTSerialOverrunErr            = $20;
  109.     kOTSerialFramingErr            = $40;
  110.     kOTSerialXOffSent            = $00010000;
  111.     kOTSerialDTRNegated            = $00020000;
  112.     kOTSerialCTLHold            = $00040000;
  113.     kOTSerialXOffHold            = $00080000;
  114.     kOTSerialOutputBreakOn        = $01000000;
  115.  
  116. {
  117.  The "Handshake" option defines what kind of handshaking the serial port
  118.  will do for line flow control.  The value is a 32-bit value defined by
  119.  the function or macro SerialHandshakeData below.
  120.  For no handshake, or CTS handshake, the onChar and offChar parameters
  121.  are ignored.
  122. }
  123.     SERIAL_OPT_HANDSHAKE        = $0105;
  124.  
  125. {  These are bits to enable specific types of handshaking }
  126.     kOTSerialXOnOffInputHandshake = 1;                            {  Want XOn/XOff handshake for incoming characters     }
  127.     kOTSerialXOnOffOutputHandshake = 2;                            {  Want XOn/XOff handshake for outgoing characters     }
  128.     kOTSerialCTSInputHandshake    = 4;                            {  Want CTS handshake for incoming characters         }
  129.     kOTSerialDTROutputHandshake    = 8;                            {  Want DTR handshake for outoing characters         }
  130.  
  131. {
  132.  The "RcvTimeout" option defines how long the receiver should wait before delivering
  133.  less than the RcvLoWat number of characters.  If RcvLoWat is 0, then the RcvTimeout
  134.  is how long a gap to wait for before delivering characters.  This parameter is advisory,
  135.  and serial drivers are free to deliver data whenever they deem it convenient.  For instance,
  136.  many serial drivers will deliver data whenever 64 bytes have been received, since 64 bytes
  137.  is the smallest STREAMS buffer size. Keep in mind that timeouts are quantized, so be sure to
  138.  look at the return value of the option to determine what it was negotiated to.
  139. }
  140.     SERIAL_OPT_RCVTIMEOUT        = $0106;
  141.  
  142. {
  143.  This option defines how characters with parity errors are handled.
  144.  A 0 value will disable all replacement.  A single character value in the low
  145.  byte designates the replacement character.  When characters are received with a 
  146.  parity error, they are replaced by this specified character.  If a valid incoming
  147.  character matches the replacement character, then the received character's msb is
  148.  cleared. For this situation, the alternate character is used, if specified in bits
  149.  8 through 15 of the option long, with 0xff being place in bits 16 through 23.
  150.  Whenever a valid character is received that matches the first replacement character,
  151.  it is replaced with this alternate character.
  152. }
  153.     SERIAL_OPT_ERRORCHARACTER    = $0107;
  154.  
  155. {
  156.  The "ExtClock" requests an external clock.  A 0-value turns off external clocking.
  157.  Any other value is a requested divisor for the external clock.  Be aware that
  158.  not all serial implementations support an external clock, and that not all
  159.  requested divisors will be supported if it does support an external clock.
  160. }
  161.     SERIAL_OPT_EXTCLOCK            = $0108;
  162.  
  163. {
  164.  The "BurstMode" option informs the serial driver that it should continue looping,
  165.  reading incoming characters, rather than waiting for an interrupt for each character.
  166.  This option may not be supported by all Serial driver
  167. }
  168.     SERIAL_OPT_BURSTMODE        = $0109;
  169.  
  170. {  Default attributes for the serial ports }
  171.     kOTSerialDefaultBaudRate    = 19200;
  172.     kOTSerialDefaultDataBits    = 8;
  173.     kOTSerialDefaultStopBits    = 10;
  174.     kOTSerialDefaultParity        = 0;
  175.     kOTSerialDefaultHandshake    = 0;
  176.     kOTSerialDefaultOnChar        = $11;                            {  Control-Q }
  177.     kOTSerialDefaultOffChar        = $13;                            {  Control-S }
  178.     kOTSerialDefaultSndBufSize    = 128;
  179.     kOTSerialDefaultRcvBufSize    = 128;
  180.     kOTSerialDefaultSndLoWat    = 96;
  181.     kOTSerialDefaultRcvLoWat    = 1;
  182.     kOTSerialDefaultRcvTimeout    = 10;
  183.  
  184. {$ALIGN RESET}
  185. {$POP}
  186.  
  187. {$SETC UsingIncludes := OpenTptSerialIncludes}
  188.  
  189. {$ENDC} {__OPENTPTSERIAL__}
  190.  
  191. {$IFC NOT UsingIncludes}
  192.  END.
  193. {$ENDC}
  194.